<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>中国福利彩票</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
	<link rel="icon" href="images/favicon.png" type="image/x-icon"/>
<script src="js/jquery-1.7.2.min.js"></script>

</head>

<body>
	<div class="Header">
    	<div class="width1200">
        	<div class="left H_logo"><img src="images/logo.png" width="200" /></div>
            <div class="right H_right">  <a href="Login.html">登录</a> </div>
            <div class="clear"></div>
        </div>
    </div>
	
    <div class="width1200">
              <div class="Register">
					<div class="FPSW_t"><img src="images/Zimg31.png" /></div>
                	<div class="FPW_Sone">
                    	<table width="100%" border="0" cellspacing="5" cellpadding="0">
                          <tr>
                         	  <td align="right">手机号：</td>
                         	  <td ><input type="text" class="NPW_text" id="phoneNumShow" maxlength="11" disabled="disabled"/></td>
                          	  <td style="display: none;"><input type="text" class="NPW_text" id="phoneNum" maxlength="11" disabled="disabled"/></td>
                          </tr>
                          <tr>
                            <td align="right">验证码：</td>
                            <td>
                            	<div class="NPW_yan">
                                	<input type="text" class="NPW_text1" id="smsCode" maxlength="8"/>
                                    <input type="button" id="smsCodeBtn" value="获取验证码" class="NPW_but" onclick="getVerificationCode()"/>
                                    <div class="clear"></div>
                                </div>
                            </td>
                          </tr>
                          <tr>
                            <td align="right">新密码：</td>
                            <td><input type="password" class="NPW_text" id="newpwd"/></td>
                          </tr>
                          <tr>
                            <td align="right">确认密码：</td>
                            <td><input type="password" class="NPW_text" id="repwd"/></td>
                          </tr>
                          <tr>
                            <td align="right">&nbsp;</td>
                            <td><input type="submit" value="确认" class="NAP_but" onclick="sureBtn()"/></td>
                          </tr>
                        </table>
                  </div>
                </div>
    </div>
    
    <div class="Footer">
    	<div class="width1200">
        	<div class="left">版权所有：中国福利彩票发行管理中心    网站主办：中国福利彩票发行管理中心</div>
            <div class="right"><img src="images/Flogo.png" width="110" /></div>
            <div class="clear"></div>
        </div>
    </div>
</body>
<script type="text/javascript">
var accountId="";
var channelId="";
jQuery(document).ready(function($){
	$('#phoneNum').attr('value',GetQueryString("phoneNum"));
	$('#phoneNumShow').attr('value',GetQueryString("phoneNum").substring(0,3)+"*****"+GetQueryString("phoneNum").substring(8,11));
	 accountId=GetQueryString("accountId");
	 channelId = getCookie("channelId");
});
//获得“短信验证码”
function getVerificationCode() {
   //验证手机号格式
	if(!validatePhoneNum('phoneNum')){
		return;
	}
  var para = {
		  mobile:$('#phoneNum').val(),
		  type:0
        };
$.ajax({
	url : "/api/CrmSystem/verification/msgcode",
	async:false,
	type : "POST",
	herder:{
		'Accept':'application/json',
		'Content-Type':'application/json'
	},
	dataType:"json",
	contentType:"application/json",
	data:JSON.stringify(para),
	error:function(XMLHttpRequest, textStatus, errorThrown){
		alert(errorThrown);
	},
	success: function(data, textStatus){
		if(data.success==true){
			messageCodeTime('smsCodeBtn');
		}else{
			alert("error:"+data.description);
		}
	}		
});
}   
function sureBtn(){
	//验证手机号
	if(!validatePhoneNum('phoneNum')){
		return;
	}
	//验证短信验证码
	if(!validatesmsCode('smsCode')){
		return;
	}
	//验证新密码与确认密码是否一致
	if(!validateRecoverLoginPwd('newpwd','repwd')){
		return;
	}
	
  var para = {
		  	accountId:accountId,
		  	mobile:$('#phoneNum').val(),
		  	newPassword:sha256_digest($('#newpwd').val()),
		  	smsCode:$('#smsCode').val(),
			channelId:channelId
        };
	
	$.ajax({
		url : "/api/CrmSystem/account/pwdRecover",
		async:false,
		type : "POST",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		data: JSON.stringify(para),
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
// 			var obj = eval("("+data+")"); 
			if(data.success == true){
				window.location.href='FPWWin.html';
			}else{
				alert("error:"+data.description);
				window.location.href='FPWDown.html';
				return;
			}
		}		
	});
}

</script>
<script src="js/SHA256.js"></script>
<script src="js/jsCallCookies.js"></script>
<script src="js/validation.js"></script>
<script src="js/countDown.js"></script>
<script src="js/common.js"></script>
</html>